
package com.scs.application.modules.report.service;

import com.scs.application.core.service.IBaseService;
import com.scs.application.modules.report.entity.Config;
import com.scs.application.modules.report.entity.GridField;
import com.scs.application.modules.report.service.impl.ConfigServiceImpl;

import java.util.List;
import java.util.Map;

/**
 * 报表配置 service 接口
 */
public interface ConfigService extends IBaseService<Config> {


    /**
     * 提取报表数据
     *
     * @param id
     * @param params
     */
    Map<String, Object> fetchData(String id, Map<String, Object> params) throws Exception;

    /**
     * 提取报表数据
     * @param id
     * @param forcePaging 是否强制分页，为 {@code false} 时，不管报表如何，都不进行分页
     * @param params
     * @return
     */
    Map<String, Object> fetchData(String id, boolean forcePaging, Map<String, Object> params) throws Exception;


    ConfigServiceImpl.FetchResult fetchSqlData(Config config, boolean forcePaging, Map<String, Object> params) throws Exception;

    /**
     * SQL解析
     *
     * @param sql
     * @param datasourceId
     * @param params
     * @return 返回所有的列名
     */
    List<Map<String, Object>> sqlParse(String sql, String datasourceId, Map<String, Object> params);

    /**
     * copy一张报表副本。所有表格字段/图表字段一起copy
     * @param id
     * @return
     */
    Config copy(String id,String codeNew);

    /**
     * 获取表头
     * @param id
     * @return
     */
    List<GridField> getGridFields(String id);

    /**
     * 获取数据列
     * @param config
     * @return
     */
    List<String> getDataColumns(Config config, Map<String, Object> params) throws Exception;

    /**
     * 自动填充表格列
     * @param config
     * @return
     */
    Boolean autoGridFields(Config config) throws Exception;

    Map<String, Object> fetchDataForPrint(String id, Map<String, Object> params) throws Exception;
}
